package com.qf.shixi.controller;

import com.qf.shixi.entity.Pic;
import com.qf.shixi.result.ResponseData;
import com.qf.shixi.service.PicService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * (Pic)表控制层
 *
 * @author
 * @since 2021-10-13 10:40:27
 */
@RestController
@RequestMapping("pic")
public class PicController {

    @Autowired
    private PicService picService;

    @ApiOperation(value = "通过状态和类型获取对应的图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name="type", value = "轮播/导航",dataType = "string",required = true),
            @ApiImplicitParam(name="status", value = "0/1",required = true),
    })
    @GetMapping("/api/query/{type}/{status}")
    public ResponseData queryByType(@PathVariable("status") Integer status, @PathVariable("type") String type){
        return picService.queryByType(type,status);
    }


    @ApiOperation(value = "查询所有图片")
    @GetMapping("/all")
    public ResponseData queryAll(){
        List<Pic>  pics = picService.queryAll();
        return new ResponseData("0","success",pics);
    }


}
